﻿using System;
using System.Collections.Generic;
using System.Text;
using Emerson.Storage.Agent.Core;
using Emerson.Storage.Agent.DeviceAccess;
using HyenaLib;

namespace GreenCubeBattery
{
    public class GreenCubeBatteryAccess : IBatteryAccess
    {
        Hyena hyena = new Hyena();
        public GreenCubeBatteryAccess()
        {
        }

        public BatteryInfo GetBatteryInfo()
        {
            BatteryInfo bi = new BatteryInfo();
            bi.BatteryType = "GreenCube";
            bi.Chemistry = Chemistry();
            bi.PercentRemaining = PercentRemaining();
            return bi;
        }

        private double PercentRemaining()
        {
            return hyena.GetParameterValue(Hyena.BatteryParameters.P003_Relative_State_Of_Charge);
        }

        private string Chemistry()
        {
            double systemtype = hyena.GetParameterValue(Hyena.BatteryParameters.P001_System_Type);

            if (systemtype == 1)
            {
                return "Li-Nano";
            }
            if (systemtype == 2)
            {
                return "NiMH";
            }
            return "Unknown";
        }
    }
}
